package com.taotao.search.controller;

import java.io.IOException;

import org.apache.solr.client.solrj.SolrServerException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.taotao.common.pojo.TaotaoResult;
import com.taotao.common.utils.ExceptionUtil;
import com.taotao.search.service.ItemService;

@Controller
@RequestMapping("/manage")
public class ItemController {
	@Autowired
	private ItemService itemService;

	@RequestMapping("/importAll")
	@ResponseBody
	public TaotaoResult importAllItems() {
		TaotaoResult result;
		try {
			result = itemService.importAllItems();
		} catch (SolrServerException | IOException e) {

			e.printStackTrace();

			e.printStackTrace();

			String msg = ExceptionUtil.getStackTrace(e);
			return TaotaoResult.build(500, msg);
		}

		return result;
	}
}
